//
//  TCollectionViewCell.m
//  test
//
//  Created by Zhen Huang on 17/10/18.
//  Copyright © 2017年 huangzhen. All rights reserved.
//

#import "TCollectionViewCell.h"

@interface TCollectionViewCell ()<UITextFieldDelegate>


@property (nonatomic, assign) NSInteger section;
@property (nonatomic, assign) NSInteger index;


@end

@implementation TCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        [self setUpLayoutWithFrame:frame];
//        self.textfield.delegate = self;

    }
    return self;
}
- (void)arrangeCellIndex:(NSInteger)index section:(NSInteger)section {
    self.section = index;
    self.index = section;
}


- (void)setUpLayoutWithFrame:(CGRect)frame {
    
    
    self.textfield  = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, frame.size.width , frame.size.height)];
    self.textfield.borderStyle = UITextBorderStyleLine;
    self.textfield.backgroundColor = [UIColor whiteColor];
    self.textfield.textAlignment = NSTextAlignmentCenter;
    self.textfield.delegate = self;
    [self.contentView addSubview:self.textfield];
    
}

- (void)workFlowsTableViewCell:(TCollectionViewCell *)cell textFileText:(NSString *)text section:(NSInteger)section row:(NSInteger)row {
    
    NSLog(@"===%@ %ld,%ld",text ,section,row);
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(workFlowsTableViewCell:textFileText:section:row:)]) {
        
        [self.delegate workFlowsTableViewCell:self textFileText:textField.text section:self.section row:self.index];
    }
    
}

@end
